<?php

		
		//private user
		$privateUserID = $this->item->getPrivateUserID();
		if( !is_null($privateUserID) && $privateUserID != 0 ) {
			$item->getPrivateUser();
			$privateUser = $this->item->privateUser->getName(). ' (' . $this->item->privateUser->getUsername().')';
		} else {
			$privateUserID = NULL;
		}
?>
        
<script language="JavaScript">
//<!--
	//shows/hides personal item elements; marks them as required or not
	function togglePersonal(enable) {
		if(enable) {
			document.getElementById('personal_item_yes').checked = true;
			document.getElementById('personal_item_owner_block').style.display ='';
			togglePersonalOwnerSearch();
		}
		else {
			document.getElementById('personal_item_no').checked = true;
			document.getElementById('personal_item_owner_block').style.display ='none';
		}
	}

	//shows/hides personal item owner search fields
	function togglePersonalOwnerSearch() {
		//if no personal owner set, 
		if(document.getElementById('personal_item_owner_curr').checked) {
			document.getElementById('personal_item_owner_search').style.visibility = 'hidden';
		}
		else if(document.getElementById('personal_item_owner_new').checked) {
			document.getElementById('personal_item_owner_search').style.visibility = 'visible';
		}	
	}
//-->
</script>
		
<div class="headingCell1">ITEM DETAILS</div>
<div id="item_details" style="padding:8px 8px 12px 8px;">
	<table border="0" cellpadding="2" cellspacing="0">		
    	<tr>
    		<td align="right">
    			<font color="#FF0000">*</font>&nbsp;Document Title:
    		</td>
    		<td>
    			<input name="title" type="text" id="title" size="50" value="<?php print($this->item->getTitle()); ?>">
    		</td>
    	</tr>
    	<tr>
    		<td align="right">
    			Author/Composer:
    		</td>
    		<td>
    			<input name="author" type="text" id="author" size="50" value="<?php print($this->item->getAuthor()); ?>">
    		</td>
    	</tr>
    	<tr>
    		<td align="right">
    			Performer:
    		</td>
    		<td>
    			<input name="performer" type="text" id="performer" size="50" value="<?php print($this->item->getPerformer()); ?>">
    		</td>
    	</tr>
    	<tr>
    		<td align="right">
    			Document Type Icon:
    		</td>
    		<td>
    			<select name="selectedDocIcon" onChange="document.iconImg.src = this[this.selectedIndex].value;">
<?php
foreach($this->iconTypes as $icon) { //#TODO push this to base displayer,
	$selected = ($this->item->getItemIcon() == $icon['helper_app_icon']) ? ' selected="selected"' : '';
?>
					<option value="<?php print($icon['helper_app_icon']); ?>"<?php print($selected); ?>><?php print($icon['helper_app_name']); ?></option>
<?php	} ?>
				</select>
				<img name="iconImg" width="24" height="20" src="<?php print($this->item->getItemIcon()); ?>" />
   			</td>
   		</tr>
   		<tr>
   			<td align="right">
   				Book/Journal/Work Title:
   			</td>
   			<td>
   				<input name="volumeTitle" type="text" id="volumeTitle" size="50" value="<?php print($this->item->getVolumeTitle()); ?>">
   			</td>
   		</tr>
   		<tr>
   			<td align="right">
   				Volume/Edition:
   			</td>
   			<td>
   				<input name="volumeEdition" type="text" id="volumeEdition" size="50" value="<?php print($this->item->getVolumeEdition()); ?>">
   			</td>
   		</tr>
   		<tr>
	    			<td align="right">
	    				Pages/Time
	    			</td>
	    			<td>
	    				<input name="pagesTimes" type="text" id="pagesTimes" size="50" value="<?php print($this->item->getPagesTimes()); ?>">
	    			</td>
	    			<?php if ($this->item->getItemGroup() == 'ELECTRONIC') { echo "<td><small>pp. 336-371 and pp. 399-442 (78 of 719)</small></td>"; } ?>	    			
	    		</tr>
	    		<tr>
	    			<td align="right">
	    				Source/Year:
	    			</td>
	    			<td>
	    				<input name="source" type="text" id="source" size="50" value="<?php print($this->item->getSource()); ?>">
	    			</td>
	    		</tr>
				<tr><td align="right">ISBN:</td><td><input type="text" size="15" maxlength="13" value="<?php print($this->item->getISBN()); ?>" name="ISBN" /></td></tr>
                <tr><td align="right">OCLC:</td><td><input type="text" size="15" maxlength="9"  value="<?php print($this->item->getOCLC()); ?>" name="OCLC" /></td></tr>
                <tr><td align="right">ISSN:</td><td><input type="text" size="15" maxlength="8"  value="<?php print($this->item->getISSN()); ?>" name="ISSN" /></td></tr>

<?php	
		if(Account_Rd::atLeastStaff()) { //$item->isPhysicalItem()){
?>
				<tr>
					<td align="right"><?php print($this->catalogName); ?> Control Number:</td>
					<td><input type="text" name="local_control_key" size="15" value="<?php print($this->item->getLocalControlKey()); ?>" /></td>
				</tr>
<?php   } 
/*	else { 
				<tr>
					<td align="right">Control Number:</td>
					<td><input type="text" name="local_control_key" size="15" value="<?php print($item->getLocalControlKey()); ?>" /></td>
				</tr>
	} */
	
		//only allow choosing personal-item owner to staff or better
		if(Account_Rd::atLeastStaff()) {
?>

				<tr id="personal_item_row" valign="top">
					<td align="right">
						Personal Copy Owner:
					</td>
					<td>
						<div id="personal_item_choice" style="background-color:#EEDDCC;">
							<input type="radio" name="personal_item" id="personal_item_no" value="no" onChange="togglePersonal(0);" /> No
							&nbsp;&nbsp;
							<input type="radio" name="personal_item" id="personal_item_yes" value="yes" onChange="togglePersonal(1);" /> Yes
						</div>
						<div id="personal_item_owner_block" style="padding:2px 3px 15px; background-color:#DFD8C6; border-top:1px dashed #999999;">
<?php
			//if there is an existing owner, give a choice of picking new one
			if(isset($privateUser)){
?>
							<input type="radio" name="personal_item_owner" id="personal_item_owner_curr" value="old" checked="checked" onChange="togglePersonalOwnerSearch();" /> Current - <strong><?php print($privateUser); ?></strong>
							<br />
							<input type="radio" name="personal_item_owner" id="personal_item_owner_new" value="new" onChange="togglePersonalOwnerSearch();" /> New &nbsp;
<?php
			} else {	//if not, then just assume we are searching for a new one
?>
							<input type="hidden" name="personal_item_owner" id="personal_item_owner_new" value="new" />
<?php
			};
?>
							<span id="personal_item_owner_search">
<?php
				//ajax user lookup //#TODO refactor this...
				$mgr = new ajaxManager('lookupUser', null, null, null, null, false, array('min_user_role'=>3, 'field_id'=>'selected_owner'));
				$mgr->display();		
?>
							</span>
						</div>
					</td>
				</tr>
<?php	} ?>
	</table>
</div>
		
<?php	
		//only allow choosing personal-item owner to staff or better
		if (Account_Rd::atLeastStaff()) {
?>		
		<script language="JavaScript">
			//set up some fields on load
			if( document.getElementById('personal_item_owner_curr') != null ) {	//if there is already a private owner
				//select current owner
				document.getElementById('personal_item_owner_curr').checked = true;
				//show private owner block
				togglePersonal(1);			
			}
			else {
				//default to no private owner
				togglePersonal(0);
			}
		</script>
<?php
		}